package com.dd.socket.handler;

import com.dd.entity.Flock;
import com.dd.entity.SocketMsg;
import com.dd.socket.MsgHandlerInterface;

import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.tio.core.Tio;
import org.tio.core.ChannelContext;

/**
 *处理加群消息
 *@Author: 蛋蛋i
 *@Time:2017/11/28 10:24
 */
@IocBean
public class JoinGroupMessageHandler implements MsgHandlerInterface {
	
    @Override
    public Object handler(String text, ChannelContext context) {
    	SocketMsg msg = Json.fromJson(SocketMsg.class, text);
		Object body = msg.getBody();
		if(body!=null){
			Flock group = Json.fromJson(Flock.class,body.toString());
			Tio.bindGroup(context,group.getId().toString());
		}
        return null;
    }
   

}
